Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved

Chapter 15 JSP Forms : JSP Form Example

JSP Form Example
A JSP form example is provided with the TIBCO iProcess Workspace. This example can be used as a starting point to create your own custom JSP form project.
The example is in the form of an IntelliJ project that was developed using IntelliJ IDEA 7.0.4 and assumes Tomcat as the application server.
You can open and build the project using IntelliJ, or you can extract the files from the \src directory and create a project using those files in whatever Java development tool you desire.
The example IntelliJ project is located in the following directory:
InstallationHome\iprocessclientbrowser\Samples\JSPFormExample
where InstallationHome is the directory in which the installer places administrative files, such as the uninstaller, documentation, and sample code. This defaults to C:\tibco on Windows systems, and /opt/tibco on UNIX systems, but can be specified as a different directory when the TIBCO iProcess Workspace is installed.
If you build the project in IntelliJ, move the resulting JSPFormExample.war file to the webapps directory on Tomcat and start Tomcat. The form example will extract itself into a directory called JSPFormExample under TomcatHome\webapps.
If you build the project in a different Java development tool, or use an application server other than Tomcat, refer to the instructions for those tools for building and extracting .war files.
Configure iProcess Workspace to Use the JSP Form
1.
Set the ExternalFormURI parameter in the Action Processor’s configuration file, apConfig.xml. This specifies the base URL of the Web Application Server (Tomcat in this case) that is hosting your JSP Forms. For information about this parameter, see External Form URI.
2.
Create a procedure and define a normal step, or import JSPForm.xfr (which is included in the JSPFormExample project).
3.
4.
Click the Edit button on the Step Definition dialog. The FormFlow Form dialog is displayed.
5.
Enter the location of the JSPForm.jsp file. Don't enter the full URL as the base URL location is defined in the ExternalFormURI parameter (see step 1). Only specify the portion of the URL that is unique to the step.
6.
7.
Edit the JSPFormExample example project for the desired form layout and fields to be displayed.
Define the field names in the fieldNames array, the types in the fieldTypes array, and the date format in the dateFormat string.
The field names should correspond to the iProcess Engine procedure field names. The arrays are defined in JSPForm.jsp, as follows:

 
String [] fieldNames = {"TEXTFLD1", "TEXTFLD2", "TEXTFLD3",                        "NUMERIC1", "CNUMERIC1", "DATE1", "TIME1"};
 
String [] fieldTypes = {"swText", "swText", "swText", "swNumeric",                        "swComma", "swDate", "swTime"};
 
String dateFormat = "MDY";

 
The dateFormat variable can be set to “MDY”, “DMY”, or “YMD”, to indicate the order of the day, month, and year in date fields. (Time fields will be displayed in the hh:mm format.)
The position and look of these fields can be defined in the JSPForm.css cascading style sheet. For example:
#TEXTFLD1marking {
   position:relative;
   left:75px;
   top:0px;
   width:240px;
}
JSP Form Interface
The JSPForm.jsp form makes use of the interfaces defined in the JSPFormLib.java library in order to do a start case, lock item, release item, keep item, and undo item. These interfaces construct and make the request to the Action Processor. The JSPFormLib public interfaces available are as follows:
JSPFormLib Constructor
The constructor initiates the JSPFormLib with the request and field information.

 
public JSPFormLib (HttpServletRequest aRequest,
                   String [] aFieldNames,
                    String [] aFieldTypes)

 
getRequestType
This method returns the type of the request.

 
public int getRequestType()

 
The getRequestType method returns one of the following static int values:
getInitXML
This method returns the details of the XML generated by an Undo, Keep or Release button click on the form.

 
public String getInitXML()

 
startCase
This method creates and submits an Action Processor StartCase request.

 
public void startCase()

 
undoItem
This method creates and submits an Action Processor UndoItems request.

 
public void undoItem()

 
lockItem
This method creates and submits an Action Processor LockItems request.

 
public String [] lockItem()

 
keepItem
This method creates and submits an Action Processor KeepItems request.

 
public void keepItem()

 
releaseItem
This method creates and submits an Action Processor ReleaseItems request.

 
public void releaseItem()

 
 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved